package com.logistic.server.controller;


import com.logistic.server.entity.common.WebUserToken;
import com.logistic.server.entity.common.WxOpenData;
import com.logistic.server.entity.pojo.SysUser;
import com.logistic.server.service.ISysLoginService;
import me.chanjar.weixin.common.error.WxErrorException;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 微信用户信息 提供者
 *
 * @author swen
 */
@RestController
@RequestMapping("/wechat/user")
public class WechatUserController {

	@Resource
	private ISysLoginService service;

	/**
	 * 微信登录
	 * @param code 参数
	 * @return webuser
	 */
	@GetMapping("login")
	public WebUserToken login(@RequestParam("code") String code) throws WxErrorException {
		return service.login(code);
	}


	/**
	 * 微信绑定
	 * @param wxOpenData 参数
	 * @return user
	 */
	@PostMapping("bind")
	public SysUser bind(@RequestBody WxOpenData wxOpenData) {
		return service.bind(wxOpenData);
	}
}
